from django.contrib import admin
from nx.blog.models import Post

class PostAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('title',)}
    list_display = ('title', 'published', 'status', 'author')
    list_filter = ('published', 'status', 'author')
    search_fields = ('title', 'body', 'more', 'tease')
    fields = ('title', 'slug', 'markup', 'body', 'more', 'tease', 'author', 'allow_comments',
              'status', 'published', 'tags')

    def save_model(self, request, obj, form, change):
        if not change:
            obj.author = request.user
        obj.save()    

admin.site.register(Post, PostAdmin)
